﻿using IupNET;


class ZBoxSample
{

    static Dialog dlg;
    static Frame frm;
    static ZBox zbox;
    static Text text;
    static ComboList list;
    static Label lbl;
    static Button btn;
    static ComboList frame;


    static void Main()
    {

        
        Iup.Open();

        frame = new ComboList("Test", "XXX") { DropDown = true, SelectedIndex = 1,Title="List" };
        text = new Text { Expand = Expand.Yes, Value = "Enter your text here" };
        lbl = new Label { Title = "This element is a label" };
        btn = new Button { Title = "This button does nothing" };


        /* Creates zbox with four elements */
        zbox = new ZBox(frame, text, lbl, btn) { Alignment = Alignment.Center, Value = text };

        frm = new Frame(
            new HBox(
                list = new ComboList("frame", "text", "lbl", "btn") { SelectedIndex = 1, Action = ListCB }
            ) { Title = "Select an element" }
        );

        /* Creates dialog */
        dlg = new Dialog(new VBox(frm, zbox) {Margin=new Size2i(10,10),Gap = 10 }); //todo: enable margin when we have our own size structure
 
        dlg.Title = "ZBox example";


        dlg.ShowXY(DialogPos.Center, DialogPos.Center);
        Iup.MainLoop();
        Iup.Close();
    }


    static void ListCB(CallbackData e)
    {
        if (e.Active)
        {
            switch (e.Value)
            {
                case 0: zbox.Value = frame; break;
                case 1: zbox.Value = text; break;
                case 2: zbox.Value = lbl; break;
                case 3: zbox.Value = btn; break;
            }
        }
    }
    

}